import sys
import os
import atexit
from PyQt5.QtWidgets import QApplication
from app.ui.main_window import MainWindow
from app.model.bootloader import BootloaderModel
from app.controller.main_controller import MainController

def main():
    """应用程序入口函数"""
    # 创建应用程序实例
    app = QApplication(sys.argv)
    
    # 创建MVC组件
    model = BootloaderModel()
    view = MainWindow()
    controller = MainController(model, view)
    
    # 初始化应用程序
    controller.initialize()
    
    # 注册应用程序退出时的清理函数
    atexit.register(controller.terminate)
    
    # 显示主窗口
    view.show()
    
    # 运行应用程序主循环
    sys.exit(app.exec_())

if __name__ == "__main__":
    main() 